#ifndef ACTION_H
#define ACTION_H

#include <windows.h>
#include <vector>
#include "button.h"
#include "easy_string.h"

//#################################

class Character;
class Action;
class ActionEvent
{
private:
	int Type;

	int KeyCode;
	
	int Param;	

	int NextActionID;

	int StartEventTime;

	int EndEventTime;
	
	int ActivePerTime;

	int ShiftSpeed;

	int AttackType;
public:
	enum {ACT_STAND, ACT_WALK, ACT_RUN, ACT_JUMP, ACT_BEATTACK, ACT_ROLL, ACT_DOWN, ACT_ATTACK_A, ACT_ATTACK_B, ACT_ATTACK_C, ACT_SKILL, ACT_COUNT};

	enum {TYPE_KEY, TYPE_SHIFT, TYPE_MOVE_CONTROL, TYPE_TURN_CONTROL, TYPE_ATTACK_TIME, TYPE_COUNT};

	enum {LEFT_KEY, RIGHT_KEY, UP_KEY, DOWN_KEY, Z_KEY, X_KEY, C_KEY, A_KEY, S_KEY, D_KEY, SPACE_KEY, KEYBROAD_COUNT};

	enum {KEY_DOWN, KEY_UP, KEY_DOUBLE, KEY_TRIGGER_DOWN, KEY_TRIGGER_UP, KEY_COUNT};

	enum {NORMAL_ATTACK, MAGIC_ATTACK, ATTACK_COUNT};

	E_STRING EventName;

	KeyBoardCheck AllKey;

	ActionEvent();

	void Save(FILE*);

	void Load(FILE*);

	void SetType(const int);

	int GetType()const;

	void SetKeyCode(const int);

	int GetKeyCode()const;

	void SetParam(const int);

	int GetParam()const;

	void SetNextID(const int);

	int GetNextID()const;

	void SetStartEventTime(const int);

	int GetStartEventTime()const;

	void SetEndEventTime(const int);

	int GetEndEventTime()const;

	void SetActivePerTime(const int);

	int GetActivePerTime()const;

	void SetShiftSpeed(const int);

	int GetShiftSpeed()const;

	void SetAttackType(const int);

	int GetAttackType()const;

	bool AttackKeyCode(int&);

	bool SkillKeyCode(Character&, int&, E_STRING&, int&);

	bool TypeKey(Character&, int&, int&, E_STRING&, int&);

	bool Work(bool, Character&, int, int&, int&, bool&, int&, E_STRING&, int&);
};

typedef std::vector <ActionEvent> V_ACTION_EVENT;

//#################################

class Action
{
private:
	int ID;
	int NextActionID;
	int EndActionTime;
public:
	E_STRING ActionName;

	E_STRING AnimateName;

	V_ACTION_EVENT vActionEvent;

	Action();

	void Save(FILE*);

	void Load(FILE*);

	void SetID(const int);

	int GetID()const;

	void SetNextID(const int);

	int GetNextID()const;

	void SetEndTime(const int);

	int GetEndTime()const;

	bool Work(bool, Character&, int, int&, int&, bool&, int&, E_STRING&, int&);
};

typedef std::vector <Action> V_ACTION;

//##################################

class ActionSystem
{
private:
	int CurAction;
	int CurTime;
	bool bChangeAct;
	bool bAttackTime;

	int AttackType;

	E_STRING SkillAnimateName;
	int SkillEndTime;
public:
	V_ACTION vAction;

	ActionSystem();

	void Save(const char*);

	void Load(const char*);

	bool IsChangeAct();

	bool IsAttackTime();

	void ChangeAction(const int);
	
	bool Work(bool, Character&, int&);

	int GetCurTime()const;

	int GetAttackType()const;

	E_STRING GetActName()const;

	int GetAction()const;

	void Draw(HDC hdc, float x, float y);
};

#endif